using System;
using System.Collections.Generic;
using System.Text;
using Entities;
using DAL;

namespace BUS
{
   public  class tbKhachHangBUS
    {
        public static void Insert(tbKhachHang khachhang)
        {
            tbKhachHangDAL khachhangDAL = new tbKhachHangDAL();
            khachhangDAL.Insert(khachhang);

        }
        public static void Uptate(tbKhachHang khachhang)
        {
            tbKhachHangDAL khachhangDAL = new tbKhachHangDAL();
            khachhangDAL.Update(khachhang);

        }
        public static void Delete(int iD)
        {
            tbKhachHangDAL khachhangDAL = new tbKhachHangDAL();
            khachhangDAL.Delete(iD);
        }
        public static tbKhachHangCollection Get(string where, int pageindex, int pagesize, string orderby, string orderdirection, out int total)
        {
            tbKhachHangDAL khachhangDAL = new tbKhachHangDAL();
            return khachhangDAL.Get(where, pageindex, pagesize, orderby, orderdirection, out total);
        }
        public static tbKhachHangCollection GetAll()
        {
            int total = 0;
            tbKhachHangDAL khachhangDAL = new tbKhachHangDAL();
            return khachhangDAL.Get("where 1=1", 0, 0,
            tbKhachHangColumns.MaKH .ToString(),
            "ASC", out total);
        }
        public static tbKhachHang GetByID(int iD)
        {
            int total = 0;
            tbKhachHangDAL khachhangDAL = new tbKhachHangDAL();
            tbKhachHangCollection khachhangCollection = khachhangDAL.Get("where " +
            tbKhachHangColumns.MaKH .ToString() + "=" + iD.ToString(),
            0, 0, tbKhachHangColumns.MaKH .ToString(), "ASC", out total);
            if (khachhangCollection.Count > 0)
                return khachhangCollection[0];
            return null;
        }

    }
}
